<?php

namespace App\Crontab;

use Carbon\Carbon;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Crontab\Annotation\Crontab;
use Hyperf\Di\Annotation\Inject;

//#[Crontab(rule: "*/20 * * * * *", name: "test", callback: "execute", memo: "这是一个示例的定时任务")]
class TestTak
{
    #[Inject]
    private StdoutLoggerInterface $logger;

    public function execute()
    {
        $this->logger->info(date('Y-m-d H:i:s', time()));
        var_dump("one:".Carbon::now()->toDateTimeString());
    }
    //自定义定时任务,独立于全局的任务
    //#[Crontab(rule: "*/30 * * * * *",name: "foo", memo: "test")]
    public function foo()
    {
        var_dump("two:".Carbon::now()->toDateTimeString());
    }

    //#[Crontab(rule: "*/10 * * * * *",name: "getUser", memo: "稿用户信息")]
    public function getUser()
    {
        var_dump("three:".Carbon::now()->toDateTimeString());
    }
    public function isEnable(): bool
    {
        return true;
    }
}